package com.reiniot.client_demo.setting;

import android.content.pm.PackageInfo;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.widget.TextView;

import com.reiniot.client_demo.R;

import butterknife.BindView;
import butterknife.ButterKnife;


public class AboutActivity extends AppCompatActivity implements AboutContract.View {
    @BindView(R.id.toolbar)
    Toolbar mToolbar;
    @BindView(R.id.tv_about)
    TextView mTvAbout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.about_act);
        ButterKnife.bind(this);

        initView();
    }

    private void initView() {
        mToolbar.setNavigationIcon(R.drawable.back_btn);
        mToolbar.setTitle(R.string.title_activity_about);
        setSupportActionBar(mToolbar);

        try {
            PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);

            mTvAbout.setText("版本信息：" + pInfo.versionName + "(" + pInfo.versionCode + ")");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                finish();
                break;
            default:
                break;
        }

        return super.onOptionsItemSelected(item);
    }

    @Override
    public void setPresenter(AboutContract.Presenter presenter) {
    }

    @Override
    public void toast(String msg) {
    }
}
